﻿namespace NetFx.SMIL.References
{
  using System;
  using System.Text;
  using System.Collections;
  using System.Collections.Generic;

  using System.Reflection;
  using System.Reflection.Emit;
  using System.Runtime.InteropServices;

  using System.Diagnostics;
  using System.Diagnostics.CodeAnalysis;
  using System.Diagnostics.SymbolStore;
  using System.Security;
  using System.Security.Permissions;

  using NetFx.MSIL;

  /// <summary>
  /// 对属性的引用。
  /// </summary>
  public class PropertyRef:MemberRef
  {
    #region Statics
    public new static PropertyRef it()
    {
      return new PropertyRef();
    }
    public static PropertyRef of(PropertyInfo propertyInfo)
    {
      return new PropertyRef(propertyInfo);
    }
    public static PropertyRef of(string identifier)
    {
      return new PropertyRef(identifier);
    }
    #endregion
    #region Properties
    /// <summary>
    /// 获取引用类型（为属性）。
    /// </summary>
    public override DefType ReflectionType
    {
      get { return DefType.Property; }
    }
    /// <summary>
    /// 获取反射信息。
    /// </summary>
    public new virtual PropertyInfo ReflectInfo
    {
      get
      {
        return this.referenced as PropertyInfo;
      }
    }
    public override bool HasReflectInfo
    {
      get
      {
        return this.ReflectInfo != null;
      }
    }
    #endregion
    #region Constructors
    public PropertyRef() : base() { }
    public PropertyRef(PropertyInfo propertyInfo):base(propertyInfo){}
    public PropertyRef(string identifier) : base(identifier, 0) { }
    protected PropertyRef(string identifier, int namespacePrefixCount) : base(identifier, namespacePrefixCount) { }
    protected PropertyRef(string identifier, int namespacePrefixCount, int classPrefixCount) : base(identifier, namespacePrefixCount, classPrefixCount) { }
    #endregion
    #region Methods
    protected override ReflectRef OnBinding(object source)
    {
      return base.OnBinding(source as PropertyInfo);
    }
    #endregion
  }
}
